Adam Richardson's Site

Linux Kernel Notes

Table of Contents

<2022-05-01 Sun>

Logging i2c traffic

Detecting i2c devices

Tracing I2C Events

  • riptutorial: Tracing i2c events
  • As root change to the /sys/kernel/debug directory
    • If it is not mounted you can mount it with this command, mount -t debugfs none /sys/kernel/debug
  • Inside the debug directory switch to the tracing dir, cd tracing
  • Disable any current function tracer, echo nop > current_tracer
  • Enable all i2c events with, echo 1 > events/i2c/enable
  • Ensure tracing is enabled, echo 1 > tracing_on
  • View logs with this, tail -f /sys/kernel/debug/tracing/trace
irq/138-maxtouc-202     [000] ....  4415.870855: i2c_read: i2c-1 #0 a=04a f=0001 l=2
irq/138-maxtouc-202     [000] ....  4415.871066: i2c_reply: i2c-1 #0 a=04a f=0001 l=2 [01-5e]
irq/138-maxtouc-202     [000] ....  4415.871068: i2c_result: i2c-1 n=1 ret=1
  • The above is an example of what the trace logs look like